#include "Postopia.h"
#include "Display.h"
#include "Image.h"
#include "Event.h"

int main(int argc, char *argv[])
{
	printf("main()\n");
	
	srand(time(0));
	
	printf("srand()\n");
	
	Display* display = Display::getSingleton();
	
	printf("display\n");
	
	if(display->initialize() == false)
	{
		printf("Error\n");
		return -1;
	}
	
	printf("display::init\n");
	
	display->clear();
		
	printf("display clear\n");
		
	Postopia* postopia = Postopia::getSingleton();
	
	printf("after postopia\n");
	
	unsigned long ticks = SDL_GetTicks();
	
	while(Event::canPollEvent())
	{
		postopia->onRun();
		
		display->flip();
		
		//printf("FPS %d", 1000 / (SDL_GetTicks() - ticks));
		
		ticks = SDL_GetTicks();
		
		SDL_Delay(100);
	}
	
    return 0;
}
